<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/10/15 0015
 * Time: 17:10
 */

namespace Home\Controller;


class WechatController extends HomeController
{
    public function api()
    {
        import('Vendor.Wechat.TPWechat');
        $options = array(
 			'token'=>'12345678', //��д���趨��key
 			'encodingaeskey'=>'OrK50UpXmPpyQykggqRxhxmesG4tBDH39HkOnOH5UpE', //��д�����õ�EncodingAESKey
 			'appid'=>'wx4bd7473a77015cff', //��д�߼����ù��ܵ�app id
 			'appsecret'=>'b99322c1ee08f45357b49ca12f7929f8' //��д�߼����ù��ܵ���Կ
        );
        $weobj = new \TPWechat($options);
//        dump($weobj);
//        $weobj->valid();

        $type = $weobj->getRev()->getRevType();
        $fromuser = $weobj->getRev()->getRevFrom();
        trace($weobj->getRev()->getRevData());
//        $weobj->createXml();
//        trace($weobj->text("111")->reply());
        switch($type) {
            case \TPWechat::MSGTYPE_TEXT:
               //trace($weobj->text("100".$fromuser)->reply());
//                $weobj->text("100".$fromuser)->reply();
                trace("222222");
//                $result = $weobj->hongbao("100", $fromuser)->reply();
                $result = $weobj->sendHongbao("100", $fromuser);
                exit;
                break;
            case \TPWechat::MSGTYPE_EVENT:
                break;
            case \TPWechat::MSGTYPE_IMAGE:
                break;
            default:
                $weobj->text("help info")->reply();
        }
    }
}